package com.zhen.dao;

import com.zhen.pojo.Goods;
import com.zhen.pojo.User;
import com.zhen.service.GoodsService;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Mytest {
    @Test
    public void test1(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        GoodsService goodsService = context.getBean("goodsServiceImpl", GoodsService.class);
        for (Goods queryAllGood : goodsService.queryAllGoods()) {
            System.out.println(queryAllGood);
        }
    }

    @Test
    public void test2(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        GoodsMapper goodsMapper = context.getBean("goodsMapper", GoodsMapper.class);
        for (Goods queryAllGood : goodsMapper.queryAllGoods()) {
            System.out.println(queryAllGood);
        }
    }

    @Test
    public void test3(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserMapper userMapper = context.getBean("userMapper", UserMapper.class);
        User zhen = userMapper.queryUserByUsernameAndPassword("zhen","123");
        System.out.println(zhen);
    }
}
